package restaurant;

import java.util.PriorityQueue;

/**
 * Access point for the information used by the system. Grants access to the
 * data required by the functions in the system by providing getter methods,
 * therefore allowing other classes to use the data.
 * 
 * @author Odessa
 */

public class InformationAggregator
{

	/** The menu. */
	private Menu menu;

	/** The orders. */
	private CustomerOrders orders;

	/** The comments. */
	private CustomerComments comments;

	/** The offers. */
	private SpecialOffers offers;

	/** The tabs. */
	private CustomerTabs tabs;

	/** The tables. */
	private Tables tables;

	/** The queue of customers waiting to be seated. */
	private PriorityQueue<Customer> customerWaitQueue;

	/** The queue of orders to be fulfilled. */
	private PriorityQueue<Order> kitchenQueue;

	/** The instance. */
	private static InformationAggregator instance;



	/**
	 * Instantiates the Information Aggregator.
	 */
	private InformationAggregator() {
		menu = new Menu();
		orders = new CustomerOrders();
		comments = new CustomerComments();
		offers = new SpecialOffers();
		tabs = new CustomerTabs();
		tables = new Tables();
		customerWaitQueue = new PriorityQueue<>();
		kitchenQueue = new PriorityQueue<>();
	}



	/**
	 * Gets the single instance of InformationAggregator.
	 * 
	 * @return single instance of InformationAggregator.
	 */
	public static InformationAggregator getInstance()
	{
		if (instance == null)
			instance = new InformationAggregator();

		return instance;
	}



	/**
	 * Gets the menu.
	 * 
	 * @return the menu.
	 */
	public Menu getMenu()
	{
		return menu;
	}



	/**
	 * Gets the orders.
	 * 
	 * @return the orders.
	 */
	public CustomerOrders getOrders()
	{
		return orders;
	}



	/**
	 * Gets the comments.
	 * 
	 * @return the comments.
	 */
	public CustomerComments getComments()
	{
		return comments;
	}



	/**
	 * Gets the offers.
	 * 
	 * @return the offers.
	 */
	public SpecialOffers getOffers()
	{
		return offers;
	}



	/**
	 * Gets the tabs.
	 * 
	 * @return the tabs.
	 */
	public CustomerTabs getTabs()
	{
		return tabs;
	}



	/**
	 * Gets the tables.
	 * 
	 * @return the tables.
	 */
	public Tables getTables()
	{
		return tables;
	}



	/**
	 * Gets the customer wait queue.
	 * 
	 * @return the customer wait queue.
	 */
	public PriorityQueue<Customer> getCustomerWaitQueue()
	{
		return customerWaitQueue;
	}



	/**
	 * Gets the kitchen queue of orders to be prepared.
	 * 
	 * @return the kitchen queue.
	 */
	public PriorityQueue<Order> getKitchenQueue()
	{
		return kitchenQueue;
	}



	/**
	 * Adds a customer to the wait queue. Customers only added to queue if there
	 * are no available tables when they place a request for a table.
	 * 
	 * @param customer the customer to add to the queue.
	 * @return the customer's position in the wait queue.
	 */
	public int addCustomerToQueue(Customer customer)
	{
		customerWaitQueue.add(customer);

		return customerWaitQueue.size();
	}



	/**
	 * Removes a customer from the wait queue.
	 * 
	 * @param customer the customer to remove from the queue.
	 */
	public void removeCustomerFromQueue(Customer customer)
	{
		customerWaitQueue.remove(customer);
	}



	/**
	 * Adds an order to the kitchen queue.
	 * 
	 * @param order the order to add to the queue.
	 */
	public void addToKitchenQueue(Order order)
	{
		kitchenQueue.add(order);
	}



	/**
	 * Removes an order from the kitchen queue.
	 * 
	 * @param order the order to add to the queue.
	 */
	public void removeFromKitchenQueue(Order order)
	{
		kitchenQueue.remove(order);
	}
}
